package com.hkts.naturalgas.performance.service.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hkts.naturalgas.constant.PerformanceConstant;
import com.hkts.naturalgas.feign.FeignInterface;
import com.hkts.naturalgas.flow.entity.FlowInstanceinfo;
import com.hkts.naturalgas.flow.mapper.FlowInstanceinfoMapper;
import com.hkts.naturalgas.organizational.entity.HontDepartment;
import com.hkts.naturalgas.organizational.entity.HontPost;
import com.hkts.naturalgas.organizational.entity.HontUser;
import com.hkts.naturalgas.organizational.mapper.HontUserMapper;
import com.hkts.naturalgas.organizational.service.IHontDepartmentService;
import com.hkts.naturalgas.organizational.service.IHontPostService;
import com.hkts.naturalgas.organizational.service.IHontUserService;
import com.hkts.naturalgas.performance.entity.HkAssessmentInfo;
import com.hkts.naturalgas.performance.entity.HkAssessmentScore;
import com.hkts.naturalgas.performance.mapper.HkAssessmentInfoMapper;
import com.hkts.naturalgas.performance.mapper.HkAssessmentScoreMapper;
import com.hkts.naturalgas.performance.performanceTo.HontUserTo;
import com.hkts.naturalgas.performance.performanceVo.*;
import com.hkts.naturalgas.performance.service.IHkAssessmentInfoService;
import com.hkts.naturalgas.utils.CustomPage;
import com.hkts.naturalgas.utils.DateUtil;
import com.hkts.naturalgas.utils.Result;
import com.hkts.naturalgas.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author yck
 * @since 2020-12-23
 */
@Service
@Transactional
@Slf4j
public class HkAssessmentInfoServiceImpl extends ServiceImpl<HkAssessmentInfoMapper, HkAssessmentInfo> implements IHkAssessmentInfoService {
    @Autowired
    private FlowInstanceinfoMapper flowInstanceinfoMapper;

    @Autowired
    private HkAssessmentInfoMapper hkAssessmentInfoMapper;
    @Autowired
    public IHontUserService iHontUserService;
    @Autowired
    private HkAssessmentScoreMapper hkAssessmentScoreMapper;
    @Autowired
    private HontUserMapper hontUserMapper;
    @Autowired
    private FeignInterface feignInterface;
    @Autowired
    public IHontDepartmentService iHontDepartmentService;
    @Autowired
    public IHontPostService iHontPostService;
    @Override
    public IPage<HkAssessmentInfo> selectPage(Page<HkAssessmentInfo> page, HkAssessmentInfo hkAssessmentInfo) {
        QueryWrapper<HkAssessmentInfo> query = Wrappers.query();
        QueryWrapper<HkAssessmentInfo> entityWrapper = getEntityWrapper(query, hkAssessmentInfo);
        return hkAssessmentInfoMapper.selectPage(page, entityWrapper);
    }


    @Override
    public List<HkAssessmentInfo> selectList(HkAssessmentInfo hkAssessmentInfo) {
        QueryWrapper<HkAssessmentInfo> query = Wrappers.query();
        QueryWrapper<HkAssessmentInfo> entityWrapper = getEntityWrapper(query, hkAssessmentInfo);
        return hkAssessmentInfoMapper.selectList(entityWrapper);
    }

    /**
     * 公共查询条件
     *
     * @param entityWrapper
     * @return
     */
    public QueryWrapper<HkAssessmentInfo> getEntityWrapper(QueryWrapper<HkAssessmentInfo> entityWrapper, HkAssessmentInfo hkAssessmentInfo) {
        //条件拼接
        if (StringUtils.isNotBlank(hkAssessmentInfo.getCreateBy())) {
            entityWrapper.like(HkAssessmentInfo.CREATE_BY, hkAssessmentInfo.getCreateBy());
        }
              /*  if(StringUtils.isNotBlank(hkAssessmentInfo.getCreateTime())){
                entityWrapper.like(HkAssessmentInfo.CREATE_TIME,hkAssessmentInfo.getCreateTime());
                }
                if(StringUtils.isNotBlank(hkAssessmentInfo.getDelFlag())){
                entityWrapper.like(HkAssessmentInfo.DEL_FLAG,hkAssessmentInfo.getDelFlag());
                }
                if(StringUtils.isNotBlank(hkAssessmentInfo.getUpdateBy())){
                entityWrapper.like(HkAssessmentInfo.UPDATE_BY,hkAssessmentInfo.getUpdateBy());
                }
                if(StringUtils.isNotBlank(hkAssessmentInfo.getUpdateTime())){
                entityWrapper.like(HkAssessmentInfo.UPDATE_TIME,hkAssessmentInfo.getUpdateTime());
                }*/
        if (StringUtils.isNotBlank(hkAssessmentInfo.getAssessmentName())) {
            entityWrapper.like(HkAssessmentInfo.ASSESSMENT_NAME, hkAssessmentInfo.getAssessmentName());
        }
        if (StringUtils.isNotBlank(hkAssessmentInfo.getAssessmentStatus())) {
            entityWrapper.like(HkAssessmentInfo.ASSESSMENT_STATUS, hkAssessmentInfo.getAssessmentStatus());
        }
              /*  if(StringUtils.isNotBlank(hkAssessmentInfo.getEndTime())){
                entityWrapper.like(HkAssessmentInfo.END_TIME,hkAssessmentInfo.getEndTime());
                }*/
        if (StringUtils.isNotBlank(hkAssessmentInfo.getProcessInstanceId())) {
            entityWrapper.like(HkAssessmentInfo.PROCESS_INSTANCE_ID, hkAssessmentInfo.getProcessInstanceId());
        }
        return entityWrapper;
    }

    @Override
    public List<HkAssessmentInfo> getHkAssessmentInfoByProIds(List<String> ids) {
        /*
         * 查询当前用户 的id
         * */
        HontUserTo hontUserTo = feignInterface.remoteUserInfo();
        List<String> dealtWith = getDealtWith(hontUserTo.getId());

        List<HkAssessmentInfo> list = hkAssessmentInfoMapper.selectHkAssessmentInfo(dealtWith);
        return list;
    }

    @Override
    public List<ProcessNodesUserAndTime> getApparoleUserIdAndTimeByProcessId(String processInstantId) {
        QueryWrapper<HkAssessmentScore> query = Wrappers.query();
        query.eq("process_instance_id", processInstantId);
        query.lambda().orderByAsc(HkAssessmentScore::getCreateTime);
        List<HkAssessmentScore> hkAssessmentScores = hkAssessmentScoreMapper.selectList(query);
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("MM-dd HH:mm:ss");
        List<String> approvalUserIdList = new ArrayList<>();
        List<ProcessNodesUserAndTime> result = new ArrayList<>();
        for (int i = 0; i < hkAssessmentScores.size(); i++) {
            if (!approvalUserIdList.contains(hkAssessmentScores.get(i).getApprovalUserId())) {
                approvalUserIdList.add(hkAssessmentScores.get(i).getApprovalUserId());
                ProcessNodesUserAndTime pnuat = new ProcessNodesUserAndTime();
                HontUser hontUser = hontUserMapper.selectById(hkAssessmentScores.get(i).getApprovalUserId());
                pnuat.setApprovalNickName(hontUser.getNickName());
                pnuat.setCreateTime(dtf2.format(hkAssessmentScores.get(i).getCreateTime()));
                result.add(pnuat);
            }
        }
        return result;
    }

    @Override
    public Result getAssessmentMonth(CustomPage page,String nickName,String businessType,String departId) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatYM = new SimpleDateFormat("yyyy-MM");
        //返回結果用
        SimpleDateFormat formatYMResult = new SimpleDateFormat("yyyy年MM月");
        Long startTime = System.currentTimeMillis();
        List<String> departmentIds = new ArrayList<>();


        if (StringUtils.isNotBlank(departId)){
            departmentIds.addAll(Arrays.asList(departId.split(",")));
        }else {
            departmentIds.addAll(feignInterface.getDepartmentIds());
        }
        /*
         * 查询当前用户 的id
         * */
        HontUserTo hontUserTo = feignInterface.remoteUserInfo();
        /*
         * 角色等级
         * */
        String identity = feignInterface.performanceUserInfo().getResult().get("identity").toString();
        //查询所有月份

        /*
         * 查找当前用户所有待办
         *
         * */
        List<String> processIds = getDealtWith(hontUserTo.getId());
        List<String> taskIds = processIds;
        AssessmentDateQueryVo VO = new AssessmentDateQueryVo();
        VO.setLoginUserId(hontUserTo.getId());
        VO.setDepartmentIds(departmentIds);
        VO.setFirstRow(page.getFirstRow());
        VO.setLastRow(page.getLastRow());
        VO.setProcessIds(processIds);
        VO.setIdentity(identity);
        VO.setBusinessType(businessType);
        VO.setNickName(nickName);
        int firstRow=page.getPageSize().intValue()*(page.getPageNumber().intValue()-1);
        int lastRow=page.getPageSize().intValue()*(page.getPageNumber().intValue());
        //获取所有的月份
        List<String> list=new ArrayList<String>();
        List<String> monthList = hkAssessmentInfoMapper.getMonthArray(VO);
        if(monthList.size()<firstRow){

        }else if(lastRow>monthList.size()){
            list=monthList.subList(firstRow,monthList.size());
        }else{
            list=monthList.subList(firstRow,lastRow);
        }
        for(int i=0;i<list.size();i++){
            try {
                list.set(i,formatYMResult.format(formatYM.parse(list.get(i))));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return ResultUtil.data(list);
    }

    @Override
    public Result getAssessmentDatesByMonth(String month,String nickName,String businessType,String departId) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatYM = new SimpleDateFormat("yyyy-MM");
        //返回結果用
        SimpleDateFormat formatYMResult = new SimpleDateFormat("yyyy年MM月");
        try {
            month=formatYM.format(formatYMResult.parse(month));
        } catch (ParseException e) {
            e.printStackTrace();
        }

        Long startTime = System.currentTimeMillis();
        List<String> departmentIds = new ArrayList<>();


        if (StringUtils.isNotBlank(departId)){
            departmentIds.addAll(Arrays.asList(departId.split(",")));
        }else {
            departmentIds.addAll(feignInterface.getDepartmentIds());
        }
        /*
         * 查询当前用户 的id
         * */
        HontUserTo hontUserTo = feignInterface.remoteUserInfo();
        /*
         * 角色等级
         * */
        String identity = feignInterface.performanceUserInfo().getResult().get("identity").toString();
        //查询所有月份

        /*
         * 查找当前用户所有待办
         *
         * */
        List<String> processIds = getDealtWith(hontUserTo.getId());
        List<String> taskIds = processIds;
        AssessmentDateQueryVo VO = new AssessmentDateQueryVo();
        VO.setLoginUserId(hontUserTo.getId());
        VO.setDepartmentIds(departmentIds);
        VO.setProcessIds(processIds);
        VO.setIdentity(identity);
        //获取所有的月份

        VO.setMonth(month);
        VO.setBusinessType(businessType);
        VO.setNickName(nickName);
        //根据待办processInstanceId查询
        List<ProcessDateAndEmpNumVo> list = hkAssessmentInfoMapper.getAssessmentDates(VO);
        List<Map<String, Object>> mapList = new ArrayList<>();
        if (list.size() > 0) {
            List<String> dateList = new ArrayList<>();
            list.stream().forEach(processDateAndEmpNumVo -> {
                dateList.add(processDateAndEmpNumVo.getDate());
            });
            HontUserNumQueryVo vv = new HontUserNumQueryVo();

            vv.setDates(dateList);
            vv.setCurrentUserId(hontUserTo.getId());
            vv.setDepartmentIds(departmentIds);
            vv.setProcessInstanceIds(processIds);
            vv.setIdentity(identity);
            vv.setBusinessType(businessType);
            vv.setNickName(nickName);
            list = hkAssessmentInfoMapper.getHontUserNum(vv);
         log.info("用户和日期列表==》{}",list);
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> map=new HashMap<String,Object>();
                map.put("empNum",list.get(i).getEmpNum());
                map.put("dateA",list.get(i).getDate());
                mapList.add(map);
            }
        }
        return ResultUtil.data(mapList);
    }

    /*
     * 根据权限查询绩效日期和参与人数
     * */

    @Override
    public Result getAssessmentDates(CustomPage page,String nickName,String businessType,String departId) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatYM = new SimpleDateFormat("yyyy-MM");
        //返回結果用
        SimpleDateFormat formatYMResult = new SimpleDateFormat("yyyy年MM月");
        Long startTime = System.currentTimeMillis();
        List<String> departmentIds = new ArrayList<>();


        if (StringUtils.isNotBlank(departId)){
            departmentIds.addAll(Arrays.asList(departId.split(",")));
        }else {
            departmentIds.addAll(feignInterface.getDepartmentIds());
        }
        /*
         * 查询当前用户 的id
         * */
        HontUserTo hontUserTo = feignInterface.remoteUserInfo();
        /*
         * 角色等级
         * */
        String identity = feignInterface.performanceUserInfo().getResult().get("identity").toString();
        //查询所有月份

        /*
         * 查找当前用户所有待办
         *
         * */
        List<String> processIds = getDealtWith(hontUserTo.getId());

        List<String> taskIds = processIds;
        AssessmentDateQueryVo VO = new AssessmentDateQueryVo();
        VO.setLoginUserId(hontUserTo.getId());
        VO.setDepartmentIds(departmentIds);
        VO.setFirstRow(page.getFirstRow());
        VO.setLastRow(page.getLastRow());
        VO.setProcessIds(processIds);
        VO.setIdentity(identity);
        VO.setNickName(nickName);
        VO.setBusinessType(businessType);
        //获取所有的月份
        List<String> monthList = hkAssessmentInfoMapper.getMonthArray(VO);
       log.info("monthList==>{}",monthList);
        int i1 = page.getPageNumber().intValue();
        if(i1>monthList.size()){
            return ResultUtil.error("没有更多数据!");
        }
        String month = monthList.get(i1 - 1);
        VO.setMonth(month);

        //根据待办processInstanceId查询
        List<ProcessDateAndEmpNumVo> list = hkAssessmentInfoMapper.getAssessmentDates(VO);
        Map<String, List<Map<String, Object>>> resultMap = new HashMap<>();
        if (list.size() > 0) {
            List<String> dateList = new ArrayList<>();
            list.stream().forEach(processDateAndEmpNumVo -> {
                dateList.add(processDateAndEmpNumVo.getDate());
            });
            HontUserNumQueryVo vv = new HontUserNumQueryVo();

            vv.setDates(dateList);
            vv.setCurrentUserId(hontUserTo.getId());
            vv.setDepartmentIds(departmentIds);
            vv.setProcessInstanceIds(processIds);
            vv.setIdentity(identity);
            vv.setBusinessType(businessType);
            vv.setNickName(nickName);
            list = hkAssessmentInfoMapper.getHontUserNum(vv);
            Integer totalRow = 0;
            //  List<Map> assessmentDatesCount = hkAssessmentInfoMapper.getAssessmentDatesCount(VO);
            if (list.size() > 0) {
                for (int i = 0; i < list.size(); i++) {
                    List<Map<String, Object>> mapList = new ArrayList<>();
                    String time = list.get(i).getDate();
                    Date date = DateUtil.StrToDate(time + "-01");
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(date);
                    int months = cal.get(Calendar.MONTH) + 1;
                    int year = cal.get(Calendar.YEAR);
                    for (int j = 0; j < list.size(); j++) {
                        Map<String, Object> map = new HashMap<>();
                        String dateA = list.get(j).getDate();
                        Integer empNum = list.get(j).getEmpNum();
                        map.put("dateA", dateA);
                        map.put("empNum", empNum);
                        Date timeTo = DateUtil.StrToDate(dateA);
                        cal.setTime(timeTo);
                        int monthTo = cal.get(Calendar.MONTH) + 1;
                        if (months == monthTo) {
                            mapList.add(map);
                        }
                    }
                    resultMap.put(year + "年" + months + "月", mapList);
                }
            }
            page.setResultData(resultMap);
            page.setTotalRows((long) list.size());
        } else {
            List<Map<String, Object>> mapList = new ArrayList<>();
            resultMap.put(formatYMResult.format(formatYM.parse(VO.getMonth())), mapList);
            page.setResultData(resultMap);
            page.setTotalRows((long) list.size());
        }
        page.setTotalRows((long)monthList.size());
        return ResultUtil.data(page);
    }
    @Override
    public List<AssessmentDetilResultVo> getAssessmentDetil(String date,String nickName,String businessType,String departId) throws Exception {
        List<String> departmentIds = new ArrayList<>();
        if (StringUtils.isNotBlank(departId)){
            departmentIds.addAll(Arrays.asList(departId.split(",")));
        }else {
            departmentIds.addAll(feignInterface.getDepartmentIds());
        }
        /*
         * 角色等级
         * */
        String identity = feignInterface.performanceUserInfo().getResult().get("identity").toString();
        HontUserTo hontUserTo = feignInterface.remoteUserInfo();
        //获取所有待办process-task  id
        //String listApplyedTasks = feignFlow.getListApplyedTasks("");
        List<String> processIds = getDealtWith(hontUserTo.getId());
        List<String> taskIds = processIds;

        HontUserNumQueryVo vo = new HontUserNumQueryVo();
        vo.setDepartmentIds(departmentIds);
        vo.setDate(date);
        vo.setProcessInstanceIds(processIds);
        vo.setCurrentUserId(hontUserTo.getId());
        vo.setIdentity(identity);
        vo.setNickName(nickName);
        vo.setBusinessType(businessType);
        List<AssessmentDetilVo> list = hkAssessmentInfoMapper.getAssessmentDetil(vo);
        LinkedHashMap<String, Object> map = new LinkedHashMap<>();

        //返回结果
        List<AssessmentDetilResultVo> resultList = new ArrayList<>();
        List<String> depId = new ArrayList<String>();
        list.stream().forEach(assessmentDetilVo -> {
            if (depId.contains(assessmentDetilVo.getDepId())) {
                resultList.stream().forEach(assessmentDetilResultVo -> {
                    if (assessmentDetilResultVo.getDepId().equals(assessmentDetilVo.getDepId())) {
                        if (!assessmentDetilResultVo.getList().contains(assessmentDetilVo.getHontUserId())) {
                            assessmentDetilResultVo.getList().add(assessmentDetilVo.getHontUserId());
                            assessmentDetilResultVo.setEmpNum(assessmentDetilResultVo.getList().size());
                        }
                    }
                });
            } else {
                System.out.println("depId:" + assessmentDetilVo.getDepId());
                depId.add(assessmentDetilVo.getDepId());
                AssessmentDetilResultVo voResult = new AssessmentDetilResultVo();
                voResult.setDepId(assessmentDetilVo.getDepId());
                voResult.setDepTitle(assessmentDetilVo.getTitle());
                voResult.getList().add(assessmentDetilVo.getHontUserId());
                voResult.setEmpNum(voResult.getList().size());
                resultList.add(voResult);
            }
        });
        //
        for (int j = 0; j < resultList.size(); j++) {
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getDepId().equals(resultList.get(j).getDepId())) {
                    if (!resultList.get(j).getMap().containsKey(list.get(i).getProcessInstanceId())) {
                        AssessmentUserDetilResultVo vv = new AssessmentUserDetilResultVo();
                        vv.setHontUserId(list.get(i).getHontUserId());
                        vv.setNickName(list.get(i).getNickName());
                        vv.setProcessInstantId(list.get(i).getProcessInstanceId());
                        if (processIds.contains(list.get(i).getProcessInstanceId())) {
                            vv.setScoreState(PerformanceConstant.T0_BE_REVIEWED);
                            vv.setTaskId(taskIds.get(processIds.indexOf(list.get(i).getProcessInstanceId())));
                        } else {
                            if (list.get(i).getScoreState().equals("2")) {
                                vv.setScoreState(PerformanceConstant.END_OF_ASSESSMENT);
                            } else {
                                vv.setScoreState(PerformanceConstant.ALREADY_APPROVED);
                            }
                        }
                        vv.setScore(list.get(i).getScore());
                        resultList.get(j).getMap().put(list.get(i).getProcessInstanceId(), vv);
                    } else {
                        resultList.get(j).getMap().get(list.get(i).getProcessInstanceId()).setScore(resultList.get(j).getMap().get(list.get(i).getProcessInstanceId()).getScore() + list.get(i).getScore());
                    }
                }
            }
        }
        return resultList;
    }

    /**
     * 功能描述:
     * [hontUserId]  根据当前用户获取待办id(绩效)
     *
     * @return: java.util.List<java.lang.String>
     * @Author: 杨春科
     * @Date: 22/9/2022 上午10:44
     * @Description //TODO
     */
    @Override
    public List<String> getDealtWith(String hontUserId) {
        List<String> list = new ArrayList<String>();
        List<FlowInstanceinfo> backLog = flowInstanceinfoMapper.getBackLog(hontUserId,"1");
        for (int i = 0; i < backLog.size(); i++) {
            list.add(backLog.get(i).getId());
        }
        if (list.size() > 0){
            List<String> stringList = new ArrayList<String>();
            QueryWrapper<HkAssessmentScore> query = Wrappers.query();
            query.lambda().in(HkAssessmentScore::getProcessInstanceId, list)
                    .eq(HkAssessmentScore::getIsCurrentAssessment,1);
            List<HkAssessmentScore> hkAssessmentScores = hkAssessmentScoreMapper.selectList(query);
            hkAssessmentScores.forEach(hkAssessmentScore -> {
                stringList.add(hkAssessmentScore.getProcessInstanceId());
            });
            return stringList;
        }

        return list;
    }

    @Override
    public void historyData() {
        List<HkAssessmentInfo> hkAssessmentInfos = hkAssessmentInfoMapper.selectList(null);
        for (int i = 0; i < hkAssessmentInfos.size(); i++) {
            HkAssessmentInfo hkAssessmentInfo = hkAssessmentInfos.get(i);
            QueryWrapper<HkAssessmentScore> query = Wrappers.query();
            query.lambda().eq(HkAssessmentScore::getProcessInstanceId, hkAssessmentInfos.get(i).getProcessInstanceId());
            query.lambda().eq(HkAssessmentScore::getIsCurrentAssessment,"1");
            List<HkAssessmentScore> hkAssessmentScores = hkAssessmentScoreMapper.selectList(query);
            if (hkAssessmentScores.size() > 0) {
                Double sum = hkAssessmentScores.stream().mapToDouble(HkAssessmentScore::getScore).sum();
                hkAssessmentInfo.setAssessmentScore(sum.floatValue());
                hkAssessmentInfo.setHontUserId(hkAssessmentScores.get(0).getHontUserId());
                HontUser byId = iHontUserService.getById(hkAssessmentScores.get(0).getHontUserId());
                if (byId != null && byId.getDepartmentId() != null) {
                    hkAssessmentInfo.setNickName(byId.getNickName());
                    hkAssessmentInfo.setDepartmentId(byId.getDepartmentId());
                    HontDepartment byId1 = iHontDepartmentService.getById(byId.getDepartmentId());
                    hkAssessmentInfo.setDepartmentTitle(byId1.getTitle());
                }
                if(byId != null && StringUtils.isNotBlank(byId.getPostId())){
                    HontPost byId1 = iHontPostService.getById(byId.getPostId());
                    if(byId1!=null){
                        hkAssessmentInfo.setHontPostId(byId1.getId());
                        hkAssessmentInfo.setHontPostTitle(byId1.getTitle());
                    }

                }

            }
        }
        this.saveOrUpdateBatch(hkAssessmentInfos);
    }
}
